Add option to position filter to build a route out of the points kept.
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Thu, 3 Nov 2005 15:16:15 +0000 (15:16 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Thu, 3 Nov 2005 15:16:15 +0000 (15:16 +0000)
gpsbabel/position.c

index 72a7ef299d3f9a981f99c67634dde6c698250f9d..3d61962b664c0b4714d3a80962eb834ea3a14d0d 100644 (file)
@@ -36,6 +36,7 @@ static char *lonopt = NULL;
 static char *exclopt = NULL;
 static char *nosort = NULL;
 static char *maxctarg = NULL;
+static char *routename = NULL;
 static int maxct;
 
 static waypoint * home_pos;
@@ -68,6 +69,8 @@ arglist_t radius_args[] = {
                NULL, ARGTYPE_BOOL },
        {"maxcount", &maxctarg,"Output no more than this number of points",
                NULL, ARGTYPE_INT, "1", NULL },
+       {"asroute", &routename,"Put resulting waypoints in route of this name",
+               NULL, ARGTYPE_STRING, NULL, NULL },
        {0, 0, 0, 0, 0}
 };
 
@@ -274,6 +277,7 @@ radius_process(void)
        waypoint ** comp;
        int i, wc;
        queue temp_head;
+       route_head *rte_head;
 
        QUEUE_FOR_EACH(&waypt_head, elem, tmp) {
                extra_data *ed;
@@ -322,6 +326,12 @@ radius_process(void)
                qsort(comp, wc, sizeof(waypoint *), dist_comp);
        }
 
+       if (routename) {
+               rte_head = route_head_alloc();
+               rte_head->rte_name = xstrdup(routename);
+               route_add_head(rte_head);
+       }
+
        /*
         * The comp array is now sorted by distance.   As we run through it,
         * we push them back onto the master wp list, letting us pass them
@@ -336,7 +346,11 @@ radius_process(void)
                if (maxctarg && i >= maxct) {
                        continue;
                }
-               waypt_add(wp);
+               if (routename) {
+                       route_add_wpt(rte_head, wp);
+               } else {
+                       waypt_add(wp);
+               }
        }
 
        xfree(comp);